package com.briup.day05;

/**
 * @author ThinkBook
 */
public class Test02_Swap {
    public static void swap(int x,int y) {
        System.out.println("交换之前,x: " + x + ",y: " + y);
        int t = x;
        x = y;
        y = t;
        System.out.println("交换之后,x: " + x + ",y: " + y);
    }

    public static void swap2(int x,int y) {
        System.out.println("交换之前,x: " + x + ",y: " + y);
        x = x ^ y;
        y = x ^ y;
        x = x ^ y;
        System.out.println("交换之后,x: " + x + ",y: " + y);
    }

    public static void main(String[] args) {
        int m = 10;
        int n = 20;

        swap(m,n);

        System.out.println("-------------");

        swap2(m,n);

        System.out.println("--------");

        swap2(m,n);

        System.out.println("swap方法后, m: " + m + ",n: " + n  );
    }

}
